seat: Add a sanity check
authorMatthias Clasen <mclasen@redhat.com>
Wed, 1 May 2019 20:46:02 +0000 (20:46 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 1 May 2019 20:46:02 +0000 (20:46 +0000)
apis that takes multiple display-relative objects
should make sure that they are all from the same
display, or hard-to-track-down badness will happen
later on.

Add such a check for the surface and device arguments
of gdk_seat_grab. This helped in tracking down
critical warnings from combo boxes in the inspector.

gdk/gdkseat.c

index ee88c6c4f2e37a6e44a457a30c2af9641d5c78fb..c13fbed615f88a697c653a0e1e1f3687d225cbd8 100644 (file)
@@ -293,6 +293,7 @@ gdk_seat_grab (GdkSeat                *seat,
 
   g_return_val_if_fail (GDK_IS_SEAT (seat), GDK_GRAB_FAILED);
   g_return_val_if_fail (GDK_IS_SURFACE (surface), GDK_GRAB_FAILED);
+  g_return_val_if_fail (gdk_surface_get_display (surface) == gdk_seat_get_display (seat), GDK_GRAB_FAILED);
 
   capabilities &= GDK_SEAT_CAPABILITY_ALL;
   g_return_val_if_fail (capabilities != GDK_SEAT_CAPABILITY_NONE, GDK_GRAB_FAILED);